package com.chenjiahao.kaiyanwan.ui.discovery

import android.os.Bundle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.chenjiahao.kaiyanwan.R
import com.chenjiahao.kaiyanwan.base.BaseFragment
import com.chenjiahao.kaiyanwan.base.BaseFragmentAdapter
import com.chenjiahao.kaiyanwan.logic.util.StatusBarUtil
import com.chenjiahao.kaiyanwan.ui.home.HomeFragment
import kotlinx.android.synthetic.main.fragment_hot.*

class DiscoveryFragment : BaseFragment() {

    private var mTitle: String? = null
    private val viewModel by lazy {
        ViewModelProvider(this).get(DiscoveryViewModel::class.java)
    }


    override fun getLayoutId(): Int = R.layout.fragment_hot


    companion object {
        fun getInstance(title: String): DiscoveryFragment {
            val fragment = DiscoveryFragment()
            val bundle = Bundle()
            fragment.arguments = bundle
            fragment.mTitle = title
            return fragment
        }
    }

    override fun initView() {
        //状态栏透明和间距处理
        activity?.let { StatusBarUtil.darkMode(it) }
        activity?.let { StatusBarUtil.setPaddingSmart(it, toolbar) }
        viewModel.stringTabs.add("关注")
        viewModel.stringTabs.add("分类")
        viewModel.fragments.add(FollowFragment.getInstance("关注"))
        viewModel.fragments.add(CategoryFragment.getInstance("分类"))
        mViewPager.adapter = BaseFragmentAdapter(childFragmentManager,viewModel.fragments,viewModel.stringTabs)
        mTabLayout.setupWithViewPager(mViewPager)

    }

    override fun lazyLoad() {

    }
}